package com.yonyou.pmclouds.workflow.extend.impl;

import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.entity.SuperVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.comprehensiveacceptance.entity.ComprehensiveAcceptanceVO;
import com.yonyou.pmclouds.processinspect.entity.ProcedureInspectVO;
import com.yonyou.pmclouds.workflow.service.rmiitf.IProcessVariableExtendService;
import com.yonyou.pmclouds.workquality.entity.WorkqualityVO;
import com.yonyou.pmclouds.workquality.service.rmiitf.WorkqualityQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class ProCheckVariableExtendServiceImpl implements IProcessVariableExtendService {

    @Autowired
    private WorkqualityQueryService workqualityQueryService;

    @Override
    public void extendProcessVariable(SuperVO businessVO) throws BusinessException {

        if(businessVO == null){
            return;
        }
        ComprehensiveAcceptanceVO checkVO = (ComprehensiveAcceptanceVO) businessVO;

        setStandardName(checkVO);

    }

    private void setStandardName(ComprehensiveAcceptanceVO checkVO) throws BusinessException {
        WorkqualityVO workqualityVO = workqualityQueryService.queryByID(checkVO.getPkInspectstandard());

        if(workqualityVO != null){
            checkVO.setInspectstandardName(workqualityVO.getCheckname());
        }
    }

    @Override
    public String getBillType() {
        return BillTypeConst.COMPREHENSIVE_ACCEPTANCE_BILLTYPE;
    }
}
